package cn.zhangyong.dbframelearn.bean;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;

import java.io.Serializable;

/**
 * description:
 * autour: zhangyong
 * date: 2019/4/3 10:08
 * update: 2019/4/3
 * version:
 */
@DatabaseTable(tableName = "note")
public class Note implements Serializable {
    @DatabaseField(generatedId = true)
    private int id;
    /*@DatabaseField(id = true)
    private Integer noteId;*/
    @DatabaseField
    private String title;
    @DatabaseField
    private String content;
    @DatabaseField
    private String lastTime;
    @DatabaseField
    private int category; // 笔记的类别

    @DatabaseField(foreign = true, foreignAutoRefresh = true)
    private Author author;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getLastTime() {
        return lastTime;
    }

    public void setLastTime(String lastTime) {
        this.lastTime = lastTime;
    }

    public int getCategory() {
        return category;
    }

    public void setCategory(int category) {
        this.category = category;
    }

    public Author getAuthor() {
        return author;
    }

    public void setAuthor(Author author) {
        this.author = author;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"id\":")
                .append(id);
        sb.append(",\"title\":\"")
                .append(title).append('\"');
        sb.append(",\"content\":\"")
                .append(content).append('\"');
        sb.append(",\"lastTime\":\"")
                .append(lastTime).append('\"');
        sb.append(",\"category\":")
                .append(category);
        sb.append(",\"author\":")
                .append(author);
        sb.append('}');
        return sb.toString();
    }
}
